using System;

namespace Pegasus.Workflow.Service
{
	/// <summary>
	/// Exception for when the workflow is in an invalid state.
	/// </summary>
	public class WorkflowInvalidStateException : WorkflowException
	{
		// Local Instance Values
		private int m_workflowId = -1;
		private string m_currentState;
		private string m_expectedState;

		/// <summary>
		/// Initializes a new instance of the <see cref="T:WorkflowInvalidStateException"/> class.
		/// </summary>
		/// <param name="message">The message.</param>
		/// <param name="args">The args.</param>
		public WorkflowInvalidStateException( string message, params object[] args ) :
			base( message, args )
		{
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="T:WorkflowInvalidStateException"/> class.
		/// </summary>
		/// <param name="workflowId">The workflow id.</param>
		/// <param name="currentState">State of the current.</param>
		/// <param name="expectedState">The expected state.</param>
		public WorkflowInvalidStateException( int workflowId, string currentState, string expectedState ) :
			base( "Invalid state for workflow {0}, current state {1}, expected state {2}", workflowId, currentState, expectedState )
		{
			m_workflowId = workflowId;
			m_currentState = currentState;
			m_expectedState = expectedState;
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="T:WorkflowInvalidStateException"/> class.
		/// </summary>
		/// <param name="workflowId">The workflow id.</param>
		/// <param name="currentState">State of the current.</param>
		/// <param name="expectedState">The expected state.</param>
		/// <param name="message">The message.</param>
		/// <param name="args">The args.</param>
		public WorkflowInvalidStateException( int workflowId, string currentState, string expectedState, string message, params object[] args ) :
			base( message, args )
		{
			m_workflowId = workflowId;
			m_currentState = currentState;
			m_expectedState = expectedState;
		}

		/// <summary>
		/// Gets the workflow id.
		/// </summary>
		/// <value>The workflow id.</value>
		public int WorkflowId
		{
			get
			{
				return m_workflowId;
			}
		}

		/// <summary>
		/// Gets the state of the current.
		/// </summary>
		/// <value>The state of the current.</value>
		public string CurrentState
		{
			get
			{
				return m_currentState;
			}
		}

		/// <summary>
		/// Gets the expected state.
		/// </summary>
		/// <value>The expected state.</value>
		public string ExpectedState
		{
			get
			{
				return m_expectedState;
			}
		}
	}
}
